package com.sailfish.springbootdemo.dao.db5;


import com.sailfish.springbootdemo.common.DB7TableName;
import com.sailfish.springbootdemo.pojo.db5.ToolManagement;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface H3cToolManagementDao {

    @Results(id = "ToolManagementResultMap", value = {
            @Result(column = "Ver", property = "Ver", jdbcType = JdbcType.VARCHAR),
            @Result(column = "CPitem", property = "CPitem", jdbcType = JdbcType.VARCHAR),
            @Result(column = "WF_DocCreated", property = "WF_DocCreated", jdbcType = JdbcType.VARCHAR),
            @Result(column = "GZitem", property = "GZitem", jdbcType = JdbcType.VARCHAR),
            @Result(column = "GZremark", property = "GZremark", jdbcType = JdbcType.VARCHAR),
            @Result(column = "GZtype", property = "GZtype", jdbcType = JdbcType.VARCHAR),
            @Result(column = "GZdesc", property = "GZdesc", jdbcType = JdbcType.VARCHAR),

    })
    @Select("<script>" +
            "select * from " + DB7TableName.TB_TABLE_TOOLING_MANAGEMENT +
            "<where>" +
            "<if test='entity != null '>" +
            "<if test='entity.Ver != null '>" +
            "and Ver like CONCAT('%',  #{entity.Ver}, '%')  " +
            "</if>" +
            "<if test='entity.CPitem != null '>" +
            "and CPitem like CONCAT('%',  #{entity.CPitem},'%')  " +
            "</if>" +
            "<if test='entity.WF_DocCreated != null '>" +
            "and WF_DocCreated like CONCAT('%',  #{entity.WF_DocCreated},'%')  " +
            "</if>" +
            "<if test='entity.GZitem != null '>" +
            "and GZitem like CONCAT('%',  #{entity.GZitem},'%')  " +
            "</if>" +
            "<if test='entity.GZremark != null '>" +
            "and GZremark like CONCAT('%',  #{entity.GZremark},'%')  " +
            "</if>" +
            "<if test='entity.GZtype != null '>" +
            "and GZtype like CONCAT('%',  #{entity.GZtype},'%')  " +
            "</if>" +
            "<if test='entity.GZdesc != null '>" +
            "and GZdesc like CONCAT('%',  #{entity.GZdesc},'%')  " +
            "</if>" +
            "</if>" +
            "</where>" +
            " order by WF_DocCreated desc" +
            " limit #{begin}, #{pageSize}" +
            "</script>")
    List<ToolManagement> getByEntity(@Param("entity") ToolManagement entity,
                                    @Param("begin") int begin,
                                    @Param("pageSize") int pageSize);

    @Select("<script>" +
            "select count(*) from " + DB7TableName.TB_TABLE_TOOLING_MANAGEMENT +
            "<where>" +
            "<if test='entity != null '>" +
            "<if test='entity.Ver != null '>" +
            "and Ver like CONCAT('%',  #{entity.Ver}, '%')  " +
            "</if>" +
            "<if test='entity.CPitem != null '>" +
            "and CPitem like CONCAT('%',  #{entity.CPitem},'%')  " +
            "</if>" +
            "<if test='entity.WF_DocCreated != null '>" +
            "and WF_DocCreated like CONCAT('%',  #{entity.WF_DocCreated},'%')  " +
            "</if>" +
            "<if test='entity.GZitem != null '>" +
            "and GZitem like CONCAT('%',  #{entity.GZitem},'%')  " +
            "</if>" +
            "<if test='entity.GZremark != null '>" +
            "and GZremark like CONCAT('%',  #{entity.GZremark},'%')  " +
            "</if>" +
            "<if test='entity.GZtype != null '>" +
            "and GZtype like CONCAT('%',  #{entity.GZtype},'%')  " +
            "</if>" +
            "<if test='entity.GZdesc != null '>" +
            "and GZdesc like CONCAT('%',  #{entity.GZdesc},'%')  " +
            "</if>" +
            "</if>" +
            "</where>" +
            " order by WF_DocCreated desc" +
            "</script>")
    Integer getCountBylimit(@Param("entity") ToolManagement entity);
    @Select("<script>" +
            "select * from " + DB7TableName.TB_TABLE_TOOLING_MANAGEMENT +
            " order by WF_DocCreated" +
            "</script>")
    List<ToolManagement> getAll();

}
